package com.wisdom.rpcDemon.service.impl;

import com.wisdom.base.response.ResultBean;
import com.wisdom.base.util.ResponseBuilderUtil;
import com.wisdom.core.annotation.WisdomRpcService;
import com.wisdom.rpcDemon.api.ServerService;
import com.wisdom.rpcDemon.service.ServerDemonService;
import com.wisdom.server.config.ServerRpcConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.List;

/**
 * @description: <>
 * @author: Leo
 * @date:2021-08-22 10:40
 */
@WisdomRpcService(interfaceClass = ServerService.class)
public class ServerDemonServiceImpl implements ServerDemonService, ServerService {

    private static final Logger log = LoggerFactory.getLogger(ServerDemonServiceImpl.class);

    @Autowired
    private ServerRpcConfig serverRpcConfig;

    @Override
    public ResultBean<String> getInfo(String requestId) {
        String param = serverRpcConfig.getServerIp() + ":" +
                serverRpcConfig.getServerPort() + "获取服务：getInfo 成功";
        return ResponseBuilderUtil.buildResultBean(requestId, "wisdom-000", "SUCCESS", param);
    }


    @Override
    public ResultBean<List<String>> test(String requestId) {
        List<String> list = valueTest();
        log.info("response is {}", list.toString());
        return ResponseBuilderUtil.buildResultBean(requestId, "wisdom-000", "SUCCESS", list);
    }


    private List<String> valueTest() {
        List<String> list = new ArrayList<>();

        list.add("张三");

        list.add("李四");

        return list;
    }

}
